import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:go_pet/src/features/menu/view/widgets/pet_page.dart';
import 'package:go_pet/src/theme/app_colors.dart';

class PetCatd extends StatelessWidget {
  final String title;
  final String description;
  final String imageUrl;
  final String time;
  final String tgId;

  const PetCatd({
    super.key,
    required this.title,
    required this.description,
    required this.imageUrl,
    required this.time,
    required this.tgId,
  });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        Navigator.push(
          context,
          MaterialPageRoute(
              builder: (context) => PetPage(
                  title: title,
                  description: description,
                  imageUrl: imageUrl,
                  time: time,
                  tgId: tgId)),
        );
      },
      child: Container(
        height: 170,
        decoration: BoxDecoration(
          color: const Color.fromARGB(255, 235, 235, 235),
          borderRadius: BorderRadius.circular(16),
        ),
        child: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 10),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              CachedNetworkImage(
                height: 100,
                imageUrl: imageUrl,
                errorWidget: (context, url, error) => const Icon(
                  Icons.error,
                  size: 50,
                  color: Colors.red,
                ),
                progressIndicatorBuilder: (context, url, downloadProgress) =>
                    Center(
                  child: SizedBox(
                    width: 50,
                    height: 50,
                    child: CircularProgressIndicator(
                      value: downloadProgress.progress,
                      color: AppColors.primary,
                    ),
                  ),
                ),
              ),
              Text(
                title,
                style: Theme.of(context).textTheme.titleLarge,
              ),
              const SizedBox(
                height: 5,
              ),
              Container(
                height: 25,
                decoration: BoxDecoration(
                  color: AppColors.primary,
                  borderRadius: BorderRadius.circular(16),
                ),
                child: const Center(
                  child: Text(
                    'Подробнее',
                    style: TextStyle(color: AppColors.white),
                  ),
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
